import axios from '../core/axios'

//登录
// export function login(username,password){
//     return axios.post("/api/login",{
//         username,
//         password
//     })
// }
export function login(data){
    return axios({
        url:'api/login',
        method:'post',
        data:data,
        mock:false
    })
}

//注册
export function register(data){
    return axios({
        url:'api/add',
        method:'post',
        data:data,
        mock:false
    })
}

//获取用户信息
// export function getinfo(){
//     return axios({
//         url:'/admin/getinfo',
//         method:'post',
//         // mock:true 默认为true 所以可以不写
//     })
// }

// //获取商品销售信息
// export function getProductSale(){
//     return axios.get("/home/getTableData")
// }
export function getProductSale(){
    return axios({
        url:'/home/getTableData',
        method:'get'
    })
}



// //获取订单相关数据
export function getOrderData(){
    return axios({
        url:'/home/getOrderData',
        method:'get'
    })
}

// //获取echarts图表数据
export function getChartData(){
    return axios({
        url:'/home/getChartData',
        method:'get'
    })
}

//获取用户列表数据
export function getUserLists(params){
    return axios({
        url:'user/list',
        method:'get',
        data:params,
        mock:false
    })
}

//删除用户
export function deleteUser(data){
    return axios({
        url:'user/delete',
        method:'post',
        data:data,
        mock:false
    })
}

//保存编辑
export function saveUserEdit(data){
    return axios({
        url:'user/edit',
        method:'post',
        data:data,
        mock:false
    })
}

//获取商品列表
export function getGoodList(params){
    return axios({
        url:'goods/list',
        method:'get',
        data:params,
        mock:false
    })
}

//检测是否为超级管理员
export function checkIsAdmin(params){
    return axios({
        url:'user/isAdmin',
        method:'get',
        data:params,
        mock:false
    })
}

//获取用户个人中心数据
export function getPersonInfo(params){
    return axios({
        url:'user/person',
        method:'get',
        data:params,
        mock:false
    })
}

//保存个人中心修改
export function savePersonInfo(data){
    return axios({
        url:'user/edit',
        method:'post',
        data:data,
        mock:false
    })
}

//改变商品状态
export function changeGoodStatus(data){
    return axios({
        url:'goods/status',
        method:'post',
        data:data,
        mock:false
    })
}

//获取商品详情
export function getGoodDetail(params){
    return axios({
        url:'goods/detail',
        method:'get',
        data:params,
        mock:false
    })
}

//保存商品修改或编辑
export function saveGoodEdit(data){
    return axios({
        url:'goods/edit',
        method:'post',
        data:data,
        mock:false
    })
}

//添加商品
export function addGood(data){
    return axios({
        url:'goods/add',
        method:'post',
        data:data,
        mock:false
    })
}

//获取文章列表
export function getArticleList(params){
    return axios({
        url:'article/list',
        method:'get',
        data:params,
        mock:false
    })
}

//获取文章详情
export function getArticleDetail(params){
    return axios({
        url:'article/detail',
        method:'get',
        data:params,
        mock:false
    })
}

//保存文章修改或编辑
export function saveArticleEditor(data){
    return axios({
        url:'article/edit',
        method:'post',
        data:data,
        mock:false
    })
}

//添加文章
export function addArticle(data){
    return axios({
        url:'article/add',
        method:'post',
        data:data,
        mock:false
    })
}
